package com.qianye.service.impl;


import com.qianye.entity.Strategy;
import com.qianye.service.StrategyBizService;
import com.qianye.service.StrategyCoreService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Strategy)表服务实现类
 *
 * @author makejava
 * @since 2024-09-16 23:44:13
 */
@Service("strategyBizService")
public class StrategyBizServiceImpl implements StrategyBizService {
    @Resource
    private StrategyCoreService strategyCoreService;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Strategy queryById(Long id) {
        return this.strategyCoreService.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param strategy 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<Strategy> queryByPage(Strategy strategy, PageRequest pageRequest) {
        return strategyCoreService.queryByPage(strategy, pageRequest);
    }

    /**
     * 新增数据
     *
     * @param strategy 实例对象
     * @return 实例对象
     */
    @Override
    public Strategy insert(Strategy strategy) {
        this.strategyCoreService.insert(strategy);
        return strategy;
    }

    /**
     * 修改数据
     *
     * @param strategy 实例对象
     * @return 实例对象
     */
    @Override
    public Strategy update(Strategy strategy) {
        this.strategyCoreService.update(strategy);
        return this.queryById(strategy.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.strategyCoreService.deleteById(id);
    }
}
